package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.options.OptionsGetModel;
import com.hzhr.iot.device.service.OptionsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "Options", description = "选项")
@RestController
@RequestMapping(value = "")
public class OptionsController extends BaseController {
    @Autowired
    OptionsService optionsService;

    //region /options GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询选项", notes="查询选项  \n简介 : 查询选项  \n步骤 :  \n1. 查询选项 : (√)  \n 根据条件参数查询选项(OPTIONS)；  \n2. 返回信息 : (√)  \n 根据条件参数和查询结果组装响应并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "is_paging", value = "是否分页", defaultValue = "false",required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where options.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_typeName", value = "筛选条件 : where options.typeName = #{equal_typeName}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "orderBy_code", value = "筛选条件 : ordrer by OptionsModel.code",required = false, dataType = "string", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_is_paging", value = "是否分页", defaultValue = "false",required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where options.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_typeName", value = "筛选条件 : where options.typeName = #{_equal_typeName}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_orderBy_code", value = "筛选条件 : ordrer by OptionsModel.code",required = false, dataType = "string", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/options", method = RequestMethod.GET)
    //endregion
    public ResponseEntity<OptionsGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws Exception {
        OptionsGetModel responseBody = optionsService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}










































































































































































































































































































































































































































































































































































































































































